import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/collect_controller.dart';

class CollectView extends GetView<CollectController> {
  const CollectView({super.key});

  Widget itemWidget(Map<String, dynamic> map) {
    return Container(
      padding: const EdgeInsets.all(16),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                map["title"],
                style: const TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 18,
                    color: Colors.black87),
              ),
              Image.asset(
                "images/play.png",
                height: 20,
                width: 20,
              )
            ],
          ),
          Text(
            map["content"],
            style: const TextStyle(fontSize: 12, color: Colors.black45),
          ),
          Container(
            margin: const EdgeInsets.fromLTRB(0, 10, 0, 0),
            color: Colors.black26,
            height: 1,
          )
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    CollectController controller = Get.put(CollectController());
    return Scaffold(
      appBar: AppBar(
          title: const Text('收藏'),
          bottom: TabBar(
            controller: controller.tabController, // 设置 TabController
            tabs: const [
              Tab(text: '收藏单词'),
              Tab(text: '已掌握单词'),
            ],
          )),
      body: Obx(() => TabBarView(
            controller: controller.tabController, // 设置 TabController
            children: [
              ListView(
                children: controller.collectLsit.map((v) {
                  return itemWidget({
                    "title": "ace",
                    "content": "n. (纸牌或骰子）幺点，佼佼者；团里的全能成员；团灭;   adj . 一流的 "
                  });
                }).toList(),
              ),
              ListView(
                children: controller.collectLsit.map((v) {
                  return itemWidget({
                    "title": "ace",
                    "content": "n. (纸牌或骰子）幺点，佼佼者；团里的全能成员；团灭;   adj . 一流的 "
                  });
                }).toList(),
              ),
            ],
          )),
    );
  }
}
